#define BYTE 0x01
#define WORD 0x02
#define FLOAT 0x03

#define DEV_TOUT    5

#define STUDENT_NUM   20
#define STUDENT_FIRST 50

typedef struct gcs_data_t
{
  // time
  unsigned long time;        // [ms]

  // euler angles
  float eul_pitch;           // euler angle, pitch, [deg]
  float eul_roll;            // euler angle, pitch, [deg]
  float eul_heading;         // euler angle, pitch, [deg]

  // 3d position and speed
  float pos_x;               // position, x, [m]
  float pos_y;               // position, y, [m]
  float pos_alt;             // position, altitude, [m]

  // air data computer
  float adc_speed;           // air data computer, indicated speed, [ms^-1]
  float adc_alt;             // air data computer, barometric altitude, [ms^-1]
  float adc_temp;            // air data computer, air temperature, [deg C]

  // power management
  float pwr_volt1;           // power management, voltage1, [V]
  float pwr_volt2;           // power management, voltage2, [V]
  float pwr_volt3;           // power management, voltage3, [V]
  float pwr_volt4;           // power management, voltage4, [V]
  float pwr_fuel;            // power management, remainging fuel, [%]

  // engine monitoring system
  float ems_rpm;    // engine monitoring system, shaft rpm, [min^-1]
  float ems_temp_head;       // engine monitoring system, temperature, head temperature, [deg C]
  float ems_temp_exhaust;    // engine monitoring system, temperature, exhaust gases, [deg C]
} gcs_data_t;

typedef struct tele_data_t
{
  // time in ms 
  unsigned long time;

  unsigned long dev_aviable;

  // imu
  float imu_acc_x;
  float imu_acc_y;
  float imu_acc_z;
  float imu_ars_x;
  float imu_ars_y;
  float imu_ars_z;
  float imu_acc_mod1_x;
  float imu_acc_mod1_y;
  float imu_acc_mod2_x;
  float imu_acc_mod2_y;
  float pitch;
  float roll;

  // tilt sensor
  float tlt_pitch;
  float tlt_roll;

  // gps 1
  float gps1_lat;
  float gps1_lon;
  float gps1_alt;
  float gps1_speed;
  float gps1_vdop;
  float gps1_hdop;

  // gps 2
  float gps2_lat;
  float gps2_lon;
  float gps2_alt;
  float gps2_speed;
  float gps2_vdop;
  float gps2_hdop;

  // magnetometer
  float mag_x;
  float mag_y;
  float mag_z;

  // air data
  float adc_alt;
  float adc_air_speed;
  float adc_vario;
  float adc_temp;
  float adc_stat_press;
  float adc_dyn_press;

  // ultrasonic range finder 1
  float usr1_range;

  // ultrasonic range finder 2
  float usr2_range;

} tele_data_t;

typedef struct student_data_t
{
  float data[STUDENT_NUM];        // veliciny ze studentskych modulu
  char  sending;                  // kolik velicin celkem posilam
	char  sendAct;                  // kolik jich posilam v aktualnim cyklu
  uint8_t  accept;                   // prijimam dalsi modul?
} student_data_t;

typedef struct student_header_t
{
  char nodeID[STUDENT_NUM];             // seznam studentskych NodeID
  uint16_t nodeChannels[STUDENT_NUM];       // kolik ma kazdy modul kanalu
  uint16_t nodeActualChannel[STUDENT_NUM];  // aktualni prijimany kanal
  uint16_t nodeOffset[STUDENT_NUM];         // offset modulu v datech
  char actualID;                        // aktualni poskytovane NodeID
} student_header_t;

typedef struct
{
  const uint8_t  node_id;  // id of device
  const uint8_t  val_num;  // number of values
  uint8_t        aviable;  // aviability of device
  uint8_t        tout;     // timeout
} can_dev_t;

#define CAN_DEV_NUM 8
#define DEV_IMU     0                                              
#define DEV_TLT     1
#define DEV_GPS1    2
#define DEV_GPS2    3
#define DEV_MM      4
#define DEV_ADC     5
#define DEV_USR1    6
#define DEV_USR2    7

#define CAN_ITM_NUM 37
typedef struct
{
  uint16_t       msg_id;    // id of message
  can_dev_t* dev;       // pointer to device info
  uint8_t       data_type; // data type
  void*      src;       // pointer to source variable
} can_itm_t;
